# coding=utf-8
from app_admin.models.admins import Admins
from flask_wtf import FlaskForm
from wtforms import StringField, SelectField, PasswordField, HiddenField
from wtforms.validators import DataRequired, length, Email, EqualTo


class UserAddForm(FlaskForm):
    email = StringField(u"邮件", [DataRequired(u"邮件不能为空"), length(1, 64), Email(u"电子邮件格式错误")], description=u'请输入电子邮件')
    tel = StringField(u'电话', [DataRequired(u"请确保输入正确位数的电话号码"), length(11)], description=u'请输入电话号码')
    role = SelectField(u'角色', [DataRequired(u'请选择角色')], description='Role')
    password = PasswordField(u'密码', [DataRequired(u"密码不能为空")], description=u'请输入密码')
    confirm_password = PasswordField(u'确认密码', [DataRequired(u"密码不能为空"), EqualTo('password', message=u'两次密码必须相同')],
                                     description=u'在此输入密码')

    def get_role(self):
        c = [(k, v) for k, v in Admins.ROLES.items()]
        c.reverse()
        self.role.choices = c


class FeedBackForm(FlaskForm):
    get_u_name = StringField(u'名称', [DataRequired(u'名称不能为空')])
    pass


